package com.atguigu.spring5.bean1.testDemo;

import com.atguigu.spring5.annotations.service.UserService;
import com.atguigu.spring5.bean1.autowire.Emp;
import com.atguigu.spring5.config.SpringConfig;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class TestAnno {

    // 测试配置类读取
    public void testConfigClass(){
        // 加载配置类 ，通过 AnnotationConfigApplicationContext
        ApplicationContext context = new AnnotationConfigApplicationContext(SpringConfig.class);
        UserService userService = context.getBean("userService",UserService.class);
        userService.add();
    }


    // 测试注解 创建对象
    @Test
    public void testAutowire(){
        ApplicationContext context = new ClassPathXmlApplicationContext("bean_anno.xml");
        UserService userService = context.getBean("userService",UserService.class);
        userService.add();
    }
}
